package com.kaiqingsun.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Arrays;

public class Demo3 {
    public static void main(String[] args) throws Exception {
        InputStream is = new FileInputStream("./hello.txt");
        //FileInputStream 可以赋值给InputStream.是因为有继承关系&&FileInputStream是InputStream的下级类
        //z准备好一个水桶
        byte[] buf = new byte[1024]; //1024表示能接到1024字节的水，桶的容量
        int n= is.read(buf);
        //n代表真正接到了多少字节的水
        //n一定小于等于1024&&n》=0
        System.out.println(n);
        //真正的数据放在buf从【0，28】
        byte[] bytes = Arrays.copyOf(buf,n);
        for (byte b :bytes){
            System.out.printf("%02x\n",b);


        }

        is.close();
    }
}
